package string;

import java.util.MissingFormatArgumentException;

/**
 * Created by L.jp
 * Description:
 * User: 86189
 * Date: 2022-10-06
 * Time: 10:57
 */
public class Test_Equals {
    public static void main(String[] args) {
        String s6 = new String("abc");
        String s7 = new String("abc");
        System.out.println(s6.equals(s7));  //重写了object的equals方法，变成了内容的比较
        
        /* equals源码：
        public boolean equals(Object anObject) {
        if (this == anObject) {
            return true;
        }
        if (anObject instanceof String) {
            String anotherString = (String)anObject;
            int n = value.length;
            if (n == anotherString.value.length) {
                char v1[] = value;
                char v2[] = anotherString.value;
                int i = 0;
                while (n-- != 0) {
                    if (v1[i] != v2[i])
                        return false;
                    i++;
                }
                return true;
            }
        }
        return false;
    } */
    
    
    }
}
